package com.xwh.shop.goods.service.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xwh.shop.goods.model.entity.Brand;
import com.xwh.shop.goods.service.mapper.BrandMapper;
import com.xwh.shop.goods.service.service.BrandService;
import org.aspectj.weaver.ast.Var;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xwh
 * @since 2025-07-16
 */
@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {

    @Override
    public IPage<Brand> pageQuery(Integer current, Integer pageSize, String name, Integer isShow) {
        LambdaQueryWrapper<Brand> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.hasText(name),Brand::getName,name);

        wrapper.eq(isShow != null,Brand::getIsShow, isShow);
        // 安装权重降序
        wrapper.orderByDesc(Brand::getSort);

        IPage<Brand> brandPage = new Page<>(current, pageSize);
        return this.page(new Page<>(current, pageSize), wrapper);
    }
}
